//
//  SDBluetoothManager.h
//  SinoDetectionDemo
//
//  Created by DCN1266 on 2022/4/19.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "SDConstant.h"
#import "SDBussinessStateModel.h"

NS_ASSUME_NONNULL_BEGIN
@class SDDeviceModel;
@class SDDetectionDataModel;

/// 已接收到数据代码块
/// @param state 业务状态对象
/// @param boundDevice 绑定的设备
typedef void(^SDBMDidReceiveData)(NSDictionary * _Nullable data,SDBussinessStateModel * _Nullable state, SDDeviceModel *boundDevice);
/// 更新绑定设备 uuid
/// @param uuidString uuid字符串
/// @param boundDevice 绑定的设备
typedef void(^SDBMDidUpdateUUIDString)(NSString * uuidString, SDDeviceModel *boundDevice);

/// 已接收到Mac地址
/// @note 针对卡迪克
/// @param mac Mac地址
/// @param boundDevice 绑定的设备
typedef void(^SDBMDidReceiveMac)(NSString * _Nullable mac, SDDeviceModel *boundDevice);

@interface SDBluetoothManager : NSObject

/// 构造蓝牙管理类单例对象
/// @return 蓝牙管理类单例对象
+ (instancetype)sharedBluetoothManager;
/// 已接收到数据代码块
@property (nonatomic, copy) SDBMDidReceiveData didReceiveData;
/// 更新绑定设备 uuid
@property (nonatomic, copy) SDBMDidUpdateUUIDString didUpdateUUIDString;
/// 已接收到Mac地址
/// @note 针对卡迪克
@property (nonatomic, copy) SDBMDidReceiveMac didReceiveMac;

/// 绑定设备
@property (nonatomic, strong) NSArray<SDDeviceModel*> *boundDevices;
@property (nonatomic, assign) NSInteger currentNumber;
/// 803 历史数据标识
@property (nonatomic, assign) BOOL is803History;
/// 阻抗值
@property (nonatomic, strong) NSMutableDictionary *weightDataDic;

/// 连接多台设备
- (void)connectDevices;
/// 连接某一款设备
- (void)connectDeviceWithBoundDevice: (SDDeviceModel *)boundDevice;
/// 断开连接多台设备
- (void)disconnectDevices;
/// 断开某一款设备
- (void)disconnectDeviceWithBoundDevice: (SDDeviceModel *)boundDevice;
/// 停止扫描（外界未传入设备信息，SDK内部会进行扫描操作，使用此方法停止扫描）
- (void)stopScan;
/// 写命令到某设备
/// @discussion 当设置时间时，content赋值时间，格式为@"yyyy-MM-dd HH:mm:ss"，年的范围为2000-2
///099，蓝牙WL-1型支持到分
///
/// 当设置校正码时，content赋值校正码，格式为@"23"，校正码有取值范围，蓝牙WL-1型为1-40
///
/// 当写读历史数据或清历史数据命令字到金准+时，content为数据类型，比如@"1"，血糖；@"2"，血糖质控
/// @param command 命令字
/// @param content 内容数据
/// @param boundDevice 绑定的设备对象
- (void)writeCommand:(SDCCommandType)command content:(NSString * _Nullable)content boundDevice:(SDDeviceModel *)boundDevice;

@end

NS_ASSUME_NONNULL_END
